//自定义模板组件
Vue.component('mydiv', {
    template: `
        <div>
            <ul>
                <li v-for="name in arr" @click="fn(name)">{{name}}</li>
            </ul>
        </div>
    `,
    data:function () { //模板组件不能访问Vue对象中的变量和方法
        return {arr: ["刘备", "关羽", "张飞"]}
    },
    methods: {
        fn: function (name) {
            alert(name);
        }
    }
})

let v = new Vue({
    el: "mydiv",
})